#include "StdAfx.h"
#include "AIGoal.h"


AIGoal::AIGoal(void)
{
}


AIGoal::~AIGoal(void)
{

}


int AIGoal::calcGoalValue(EntityControl *entity)
{

	int result = 0;

	for(int i=0; i< recordList.size(); i++)
	{
		//EntityControl* entity = entityMap[recordList[i]->entity];
		int diff =*(recordList[i]->goal) - (*entity->getParameter(recordList[i]->param));

		diff *= recordList[i]->weight;
		if(recordList[i]->negate)
		{
			diff *= -1;
		}

		result += diff;

	}


	Ogre::LogManager::getSingleton().logMessage("		Calculated goal value "+Ogre::StringConverter::toString(result));
	return result;
}

void AIGoal::addGoalRecord(AIGoalRecord* goal)
{
	recordList.push_back(goal);

}

void AIGoal::addInvolvedEntity(Ogre::String name, EntityControl *entity)
{

	 entityMap[name] = entity;
}

std::vector<Trigger*>*AIGoal::getTriggerList()
{
	return &triggerList;

}

void AIGoal::addTrigger(Trigger * t)
{
	triggerList.push_back(t);

}